home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / C⁄C++ OS8 / Everything / ModelessCheckboxes.cp < prev    next >
Encoding:
Text File  |  1998-09-06  |  5.2 KB  |  199 lines  |  [TEXT/CWIE]

  1. // ModelessCheckboxes.cp -- modeless dialog
  2.  
  3. #include <Types.h>
  4. #include <Quickdraw.h>
  5. #include <Controls.h>
  6. #include <Dialogs.h>
  7. #include <Events.h>
  8. #include <Lists.h>
  9. #include <Menus.h>
  10. #include <TextEdit.h>
  11. #include <Appearance.h>
  12.  
  13. #include "ResourceDefs.h"
  14. #include "Miscellany.h"
  15. #include "ControlUtils.h"
  16.  
  17. #include "ModelessCheckboxes.h"
  18.  
  19. #define kStandardCheck        1
  20. #define kXxCheck        2
  21. #define kCapTriangleLabel        3
  22. #define kGraphicBox        4
  23. #define kCapcicnLabel        5
  24. #define kLRCheck        6
  25. #define kCapicl8Label        7
  26. #define kLR2Check        8
  27. #define kCapICNLabel        9
  28. #define kLR3Check        10
  29. #define kCapPICTLabel        11
  30. #define kLR4Check        12
  31. #define kCapicl9Label        13
  32. #define kCheckboxCheck        14
  33. #define kBevelBox        15
  34. #define kCheckbox2Check        16
  35. #define kNextCheck        17
  36. #define kNext2Check        18
  37.  
  38.  
  39. //----------
  40. CModelessCheckboxes*        CModelessCheckboxes::sDialog = nil;
  41.  
  42. //----------
  43. // static
  44. CModelessCheckboxes*        CModelessCheckboxes::Create ()
  45. {
  46.     CModelessCheckboxes*        dialog = new CModelessCheckboxes;
  47.     DModelessCheckboxesData*        data = new DModelessCheckboxesData;
  48.  
  49.     dialog->MakeDialog (DLOG_ModelessCheckboxes);
  50.     dialog->ConnectToData (data);
  51.  
  52.     return dialog;
  53. }
  54.  
  55. //----------
  56. // static
  57. CModelessCheckboxes*        CModelessCheckboxes::Show ()
  58. {
  59.     if (sDialog == nil) {
  60.         sDialog = CModelessCheckboxes::Create ();
  61.     }
  62.     if (sDialog != nil) {
  63.         ::SelectWindow (sDialog->mDialog);
  64.         ::ShowWindow (sDialog->mDialog);
  65.     }
  66.     return sDialog;
  67. }
  68.  
  69. //----------
  70. CModelessCheckboxes::CModelessCheckboxes ()
  71. {
  72.     mData = nil;
  73. }
  74.  
  75. //----------
  76. CModelessCheckboxes::~CModelessCheckboxes ()
  77. {
  78.     sDialog = nil;
  79. }
  80.  
  81. //----------
  82. void    CModelessCheckboxes::FinishMake ()
  83. {
  84.     mStandardHandle = GetControlItem (kStandardCheck);
  85.     mXxHandle = GetControlItem (kXxCheck);
  86.     mGraphicHandle = GetControlItem (kGraphicBox);
  87.     mLRHandle = GetControlItem (kLRCheck);
  88.     mLR2Handle = GetControlItem (kLR2Check);
  89.     mLR3Handle = GetControlItem (kLR3Check);
  90.     mLR4Handle = GetControlItem (kLR4Check);
  91.     mCheckboxHandle = GetControlItem (kCheckboxCheck);
  92.     mBevelHandle = GetControlItem (kBevelBox);
  93.     mCheckbox2Handle = GetControlItem (kCheckbox2Check);
  94.     SetBevelButtonGraphicAlignment (mCheckbox2Handle, kControlBevelButtonAlignCenter, 0, 0);
  95.     mNextHandle = GetControlItem (kNextCheck);
  96.     SetBevelButtonTextPlacement (mNextHandle, kControlBevelButtonPlaceToRightOfGraphic);
  97.     SetBevelButtonTextAlignment (mNextHandle, kControlBevelButtonAlignTextFlushLeft, 0);
  98.     SetBevelButtonGraphicAlignment (mNextHandle, kControlBevelButtonAlignLeft, 0, 0);
  99.     mNext2Handle = GetControlItem (kNext2Check);
  100.     SetBevelButtonTextPlacement (mNext2Handle, kControlBevelButtonPlaceBelowGraphic);
  101.     SetBevelButtonTextAlignment (mNext2Handle, kControlBevelButtonAlignTextCenter, 0);
  102.     SetBevelButtonGraphicAlignment (mNext2Handle, kControlBevelButtonAlignTop, 0, 0);
  103. }
  104.  
  105. //----------
  106. void    CModelessCheckboxes::ConnectToData (
  107.     AMSignaler*        inData)
  108. {
  109.     AMDialog::ConnectToData (inData);
  110.     mData = (DModelessCheckboxesData*) inData;
  111.  
  112.     SetControlValue (mStandardHandle, mData->GetStandard7 ());
  113.     SetControlValue (mXxHandle, mData->GetXx3 ());
  114.     SetControlValue (mLRHandle, mData->GetLR9 ());
  115.     SetControlValue (mLR2Handle, mData->GetLR10 ());
  116.     SetControlValue (mLR3Handle, mData->GetLR11 ());
  117.     SetControlValue (mLR4Handle, mData->GetLR12 ());
  118.     SetControlValue (mCheckboxHandle, mData->GetCheckbox5 ());
  119.     SetControlValue (mCheckbox2Handle, mData->GetCheckbox6 ());
  120.     SetControlValue (mNextHandle, mData->GetNext5 ());
  121.     SetControlValue (mNext2Handle, mData->GetNext6 ());
  122. }
  123.  
  124. //----------
  125. void    CModelessCheckboxes::DataChanged (
  126.     long        inDataID)
  127. {
  128.     if (inDataID == idStandard7) {
  129.         SetControlValue (mStandardHandle, mData->GetStandard7 ());
  130.     }
  131.     if (inDataID == idXx3) {
  132.         SetControlValue (mXxHandle, mData->GetXx3 ());
  133.     }
  134.     if (inDataID == idLR9) {
  135.         SetControlValue (mLRHandle, mData->GetLR9 ());
  136.     }
  137.     if (inDataID == idLR10) {
  138.         SetControlValue (mLR2Handle, mData->GetLR10 ());
  139.     }
  140.     if (inDataID == idLR11) {
  141.         SetControlValue (mLR3Handle, mData->GetLR11 ());
  142.     }
  143.     if (inDataID == idLR12) {
  144.         SetControlValue (mLR4Handle, mData->GetLR12 ());
  145.     }
  146.     if (inDataID == idCheckbox5) {
  147.         SetControlValue (mCheckboxHandle, mData->GetCheckbox5 ());
  148.     }
  149.     if (inDataID == idCheckbox6) {
  150.         SetControlValue (mCheckbox2Handle, mData->GetCheckbox6 ());
  151.     }
  152.     if (inDataID == idNext5) {
  153.         SetControlValue (mNextHandle, mData->GetNext5 ());
  154.     }
  155.     if (inDataID == idNext6) {
  156.         SetControlValue (mNext2Handle, mData->GetNext6 ());
  157.     }
  158. }
  159.  
  160.  
  161. //----------
  162. void    CModelessCheckboxes::DoItem (
  163.     SInt16        inItemHit)
  164. {
  165.     switch (inItemHit) {
  166.     case kStandardCheck:
  167.             mData->SetStandard7 (ToggleCheckbox (mStandardHandle));
  168.         break;
  169.     case kXxCheck:
  170.             mData->SetXx3 (ToggleCheckbox (mXxHandle));
  171.         break;
  172.     case kLRCheck:
  173.             mData->SetLR9 (ToggleCheckbox (mLRHandle));
  174.         break;
  175.     case kLR2Check:
  176.             mData->SetLR10 (ToggleCheckbox (mLR2Handle));
  177.         break;
  178.     case kLR3Check:
  179.             mData->SetLR11 (ToggleCheckbox (mLR3Handle));
  180.         break;
  181.     case kLR4Check:
  182.             mData->SetLR12 (ToggleCheckbox (mLR4Handle));
  183.         break;
  184.     case kCheckboxCheck:
  185.             mData->SetCheckbox5 (ToggleCheckbox (mCheckboxHandle));
  186.         break;
  187.     case kCheckbox2Check:
  188.             mData->SetCheckbox6 (GetControlValue (mCheckbox2Handle));
  189.         break;
  190.     case kNextCheck:
  191.             mData->SetNext5 (GetControlValue (mNextHandle));
  192.         break;
  193.     case kNext2Check:
  194.             mData->SetNext6 (GetControlValue (mNext2Handle));
  195.         break;
  196.  
  197.     } // switch
  198. }
  199.